<?php
namespace App\Enum;

use App\Common\BaseComm;

/**
 * 系统枚举配置项
 * @author authxch
 */
class SysEnum {
    
    function __construct() {
    }
    
    
    //TODO 系统返回消息处理等级
    const RETURN_MSG_LEVEL_1 = 1;
    const RETURN_MSG_LEVEL_2 = 2;
    const RETURN_MSG_LEVEL_3 = 3;
    
    //TODO 前端通信类型
    const PUSH_MSGTYPE_USER_MONEY = 'USER_MONEY';
    const PUSH_MSGTYPE_USER_MESSAGE = 'USER_MESSAGE';
    const PUSH_MSGTYPE_USER_OFFLINE = 'USER_OFFLINE';       //后台处理强行踢下线
    const PUSH_MSGTYPE_USER_DOWNLING = 'USER_DOWNLING';     //用户其它地方登录挤下线
    
    
    //TODO 登录缓存
    const USER_LOGIN_REDIS_KEY = "QPGAME:LoginUserInfo:Player:";       //登录用户信息存储位置
    const USER_LOGIN_FDMAP_KEY = "QPGAME:LoginUserInfo:FdMaps";        //登录用户信息存储位置
    const USER_PLAY_FDMAP_KEY = "QPGAME:LoginUserInfo:RoomFdMaps";     //登录用户信息存储位置
    const USER_OUTPLAY_FDMAP_KEY = "QPGAME:LoginUserInfo:OutFdMaps";     //登录用户信息存储位置
    const SERVER_LOGIN_CLIENTS_KEY = "QPGAME:LoginClient:FdMaps";      //玩家登录多台服务器的缓存Client数据
    const SERVER_LOGIN_SERVER_KEY = "QPGAME:LoginClient:Server";      //玩家登录多台服务器的缓存Client数据
    const AGENT_DESCMAP_KEY = "QPGAME:LoginUserInfo:AgentEKey";        //代理的KEY值；
    const ROBOT_USER_KEY = "QPGAME:Robot:GamePlayer:";                 //机器人玩家列表
    
    
    //TODO 服务器数据
    const BASEDB_GAMECOMMON_TIMERS_KEY = 'QPGAME:Common:Timers';                            //游戏中主动关闭定时器标识
    const BASEDB_GAMECOMMON_DISCONFDS_KEY = 'QPGAME:Common:DisConnFds';                     //已掉线的FD列表
    const AGENT_TONGJI_KEY = "QPGAME:AgentsBills:";                                        //代理线统计KEY
    const AGENT_TONGJI_TODAY_KEY = "QPGAME:AgentsBills:Todays";                            //当天代理线统计KEY
    const AGENT_TONGJI_MONTH_KEY = "QPGAME:AgentsBills:Months";                            //本月代理线统计KEY
    
    //TODO 缓存KEY的健名称
    const ONLINE_Lobby_USERFD_KEY = "QPGAME:LineRooms:Lobby:UFD";                  //大厅
    const ONLINE_Lobby_TIMER_KEY = "QPGAME:LineRooms:Lobby:Timer";                 //大厅定时器
    const ONLINE_GAMES_ALL_KEY = "QPGAME:LineRooms:GameLists";                     //所有游戏类型
    const ONLINE_ROOMS_LIST_KEY = "QPGAME:LineRooms:Games:";                       //房间在线用户详细数据
    const ONLINE_ROOMS_PEPNUMS_KEY = "QPGAME:LineRooms:GamesOnLines:gameIds";      //游戏在线人数统计
    const ONLINE_ROOMS_TONGJI_KEY = "QPGAME:LineRooms:GamesTongji:";               //房间在线用户详细数据
    const ONLINE_ROOMS_KEY = "QPGAME:LineRooms:RoomMaps:";                         //房间在线用户数目；计算空位值
    const ONLINE_BDATA_KEY = "QPGAME:LineRooms:BDataMaps:Bets";                    //房间中抢庄下注列表数据更新；
    const GAME_LOGS_KEY = "QPGAME:GameLogs:GameNoFightLogs";                       //游戏对局日志记录KEY
    const USERLOGS_KEY = "QPGAME:GameLogs:UserLogsLists";                          //临时日志记录KEY（写库之前存入）
    const USERWIN_NOTICE_KEY = "QPGAME:UserWinsNotice:";                            //推送玩家赢钱的记录KEY（按游戏ID存入）
    
    
    
    //TODO 房间游戏玩家KEY
    const BASEDB_GAMERID_USERS_KEY = 'QPGAME:BaseDB:joinGameRidUsers';
    const BASEDB_GAMEPLAYING_KEY = 'QPGAME:PLAYING:PlayGameUsers';
    const BASEDB_GAMERESULT_KEY = "QPGAME:PlayRes:";                                   //房间内的牌面缓存数据
    
    
    //TODO 游戏牌数据
    const BASEDB_GAMECARD_KEY = "QPGAME:BaseDB:GameRoomCard";                                       //牌数据
    const BASEDB_GAMECARD_TWO_KEY = "QPGAME:BaseDB:GameRoomCard";                                   //牌数据
    const BASEDB_GAMEROOM_MONEY_KEY = "QPGAME:BaseDB:GameRoomMoney";                                //带的金额
    const BASEDB_GAMEROOM_USERFDS_KEY = "QPGAME:BaseDB:GameRoomUserFds";                                   //房间FD
    
    
    //TODO 机器人配置
    const ROBOT_AGENTMD5_KEY = "QPGAME:LineRooms:Robots:ClientsMD5Key";                        //所有客户端的KEY值和数据(Hash列表：key=robot_id,value=object----[agentId,robotName,md5Key])
    const ROBOT_ONLINEPLAYER_KEY = "QPGAME:LineRooms:Robots:OnLinePlayer";                     //在线机器人列表（Hash列表：key=uid,value=1-在线,2-离线）
    const ROBOT_PLAYCLIENTS_KEY = "QPGAME:LineRooms:Robots:PlayingClients";                    //所有机器人(Hash列表：key=uid,value=object----[fd,name,uid,playFlag=1-正在游戏,2-空闲]，离线时从列表中删除)
    
    //TODO 重启服务器要清理掉的REDIS数据
    const CLEAR_SERVER_REDISKeys = [
        self::USER_PLAY_FDMAP_KEY,
        self::AGENT_DESCMAP_KEY,
        self::ONLINE_GAMES_ALL_KEY,
        self::ONLINE_Lobby_USERFD_KEY,
        self::ONLINE_Lobby_TIMER_KEY,
        self::ONLINE_ROOMS_PEPNUMS_KEY,
        self::ONLINE_BDATA_KEY,
        self::BASEDB_GAMECARD_KEY,
        self::BASEDB_GAMECARD_TWO_KEY,
        self::BASEDB_GAMEROOM_MONEY_KEY,
        self::BASEDB_GAMEROOM_USERFDS_KEY,
        self::BASEDB_GAMECOMMON_TIMERS_KEY,
        self::BASEDB_GAMECOMMON_DISCONFDS_KEY,
        self::ROBOT_AGENTMD5_KEY,
        self::ROBOT_ONLINEPLAYER_KEY,
        self::SERVER_LOGIN_CLIENTS_KEY,
        self::SERVER_LOGIN_SERVER_KEY,
        self::BASEDB_GAMEPLAYING_KEY,
        self::BASEDB_GAMERID_USERS_KEY,
        self::ONLINE_ROOMS_KEY.'Rooms',
        self::GAME_LOGS_KEY,
        self::USERLOGS_KEY,
        self::USERWIN_NOTICE_KEY."**",
        self::ONLINE_ROOMS_LIST_KEY.'**',
        self::ONLINE_ROOMS_TONGJI_KEY."**",
        self::ROBOT_USER_KEY.'**',
        //self::AGENT_TONGJI_KEY.'**'
    ];
    
    
    //TODO 定时交易记录类类型
    const RECODE_TYPE_INDEX1 = 1;
    const RECODE_TYPE_INDEX2 = 2;
    const RECODE_TYPE_INDEX3 = 3;
    const RECODE_TYPE_INDEX4 = 4;
    const RECODE_TYPE_INDEX5 = 5;
    const RECODE_TYPE_INDEX6 = 6;
    const RECODE_TYPE_INDEX7 = 7;
    const RECODE_TYPE_INDEX8 = 8;
    const RECODE_TYPES = [
        1=>'玩家上分',
        2=>'玩家下分',
        3=>'游戏输赢',
        4=>'增加额度',
        5=>'减少额度',
        6=>'后台加分',
        7=>'后台减分',
        8=>'优惠加分',
    ];
    
    //TODO 资金明细类型
    public static function getRecodes(){
        return self::RECODE_TYPES;
    }
    
    //TODO 后台调用FD的KEY值
    public static function getLoginFdMapKey() {
        $siteId = BaseComm::getSiteId();
        return self::USER_LOGIN_FDMAP_KEY .$siteId;
    }
    
    //TODO 机器人目录
    public static function getRobotClientKey() {
        $siteId = BaseComm::getSiteId();
        return self::ROBOT_PLAYCLIENTS_KEY .":".$siteId;
    }
}
